package jeme.lang;

/**
 * 
 * 
 * @author Erik Silkensen (silkense@colorado.edu)
 * @version Mar 20, 2009
 */
public class SchemeString extends SchemeObject
{
    private char[] string;
    
    /**
     * Creates an empty string.
     */
    public SchemeString()
    {
        this(new char[] { });
    }
    
    /**
     * Creates a <code>SchemeString</code> from the specified string. The string
     * is copied to create a new <code>SchemeString</code>.
     * 
     * @param string  the initial value of this string
     */
    public SchemeString(String string)
    {
        this(string.toCharArray());
    }
    
    /**
     * Creates a <code>SchemeString</code> from the specified character array.
     * The array is copied to create a new <code>SchemeString</code>.
     * 
     * @param string  the initial value of this string 
     */
    public SchemeString(char[] string)
    {
        this.string = new char[string.length];
        System.arraycopy(string, 0, this.string, 0, string.length);
    }
    
    /*
     * (non-Javadoc)
     * @see jeme.lang.SchemeObject#toDisplayString()
     */
    public String toDisplayString()
    {
        return new String(string);
    }
    
    /*
     * (non-Javadoc)
     * @see jeme.lang.SchemeObject#toString()
     */
    public String toString()
    {
        return "\"" + new String(string) + "\"";
    }
}
